#pragma once

#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <map>
#include <vector>
#include <OpenGL/Layer.h>
#include "ADProgram.h"

enum class LayerGroupState {
	NotDropped,
	Dropping,
	Dropped
};

class ModelLoader
{
public:
	vector<LayerGroupState> layerGroupStates;
	// model data 
	vector<Texture> textures_loaded;	// stores all the textures loaded so far, optimization to make sure textures aren't loaded more than once.
	vector<Layer*>    layers;
	vector<vector<aiMesh*>> aiMeshGroups;  
	vector<vector<Layer*>> layerGroups;
	string directory;
	ModelLoader(string const &path);
	~ModelLoader();
	// draws the model, and thus all its meshes
	void Draw(ADProgram &shader);
	void DrawLayerGroup(ADProgram &shader, std::vector<Layer*> showLayers);
private:
	void LoadModel(string const &path);
	void LoadModelToMeshGroup(string const &path);
	void ProcessNode(aiNode *node, const aiScene *scene);
	Layer *ProcessMesh(aiMesh *mesh, const aiScene *scene);
	vector<Layer*> processMeshes(vector<aiMesh*> aiMeshes, const aiScene *scene);
	vector<Texture> LoadMaterialTextures(aiMaterial *mat, aiTextureType type, string typeName);
};

